package cz.muni.fi.pa165.service.impl;

import cz.muni.fi.pa165.dao.PackageDAO;
import cz.muni.fi.pa165.dto.PackageDTO;
import cz.muni.fi.pa165.entity.Package;
import cz.muni.fi.pa165.service.PackageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;

/**
 *
 * @author Jakub Janco
 */
@Service
@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS)
public class PackageServiceImpl implements PackageService {
   
    @Autowired
    private PackageDAO packageDAO;

    public void setPackageDAO(PackageDAO packageDAO) {
        this.packageDAO = packageDAO;
    }
    
    @Transactional
    public void removePackage(PackageDTO pkg) {
        packageDAO.removePackage(new Package(pkg));
    }
    
    @Transactional
    public PackageDTO getPackageById(Long id) {
        return new PackageDTO(packageDAO.getPackageById(id));
    }
      
}
